package com.da.javatest.niuke.jianzhi;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author chenlida
 * @date 2020/10/26 14:19
 * https://www.nowcoder.com/practice/00de97733b8e4f97a3fb5c680ee10720?
 * tpId=13&tags=&title=&diffculty=0&judgeStatus=0&rp=1
 */
public class C54Solution {
    private Map<Character, Integer> map = new LinkedHashMap<>();

    public void Insert(char ch) {
        map.merge(ch, 1, (a, b) -> a + b);
    }

    public char FirstAppearingOnce() {
        for (Character ch : map.keySet()) {
            if (map.get(ch) == 1) {
                return ch;
            }
        }
        return '#';
    }
}
